package com.ruoyi.jhc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jhc.domain.JhcJszpylkc;
import com.ruoyi.jhc.service.IJhcJszpylkcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 金属制品原料库存录入Controller
 * 
 * @author lgx
 * @date 2022-10-28
 */
@RestController
@RequestMapping("/jhc/jszpylkc")
public class JhcJszpylkcController extends BaseController
{
    @Autowired
    private IJhcJszpylkcService jhcJszpylkcService;

    /**
     * 查询金属制品原料库存录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:jszpylkc:list')")
    @GetMapping("/list")
    public TableDataInfo list(JhcJszpylkc jhcJszpylkc)
    {
        startPage();
        List<JhcJszpylkc> list = jhcJszpylkcService.selectJhcJszpylkcList(jhcJszpylkc);
        return getDataTable(list);
    }

    /**
     * 导出金属制品原料库存录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:jszpylkc:export')")
    @Log(title = "金属制品原料库存录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JhcJszpylkc jhcJszpylkc)
    {
        List<JhcJszpylkc> list = jhcJszpylkcService.selectJhcJszpylkcList(jhcJszpylkc);
        ExcelUtil<JhcJszpylkc> util = new ExcelUtil<JhcJszpylkc>(JhcJszpylkc.class);
        util.exportExcel(response, list, "金属制品原料库存录入数据");
    }

    /**
     * 获取金属制品原料库存录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('jhc:jszpylkc:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(jhcJszpylkcService.selectJhcJszpylkcByCDate(cDate));
    }

    /**
     * 新增金属制品原料库存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:jszpylkc:add')")
    @Log(title = "金属制品原料库存录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JhcJszpylkc jhcJszpylkc)
    {
        return toAjax(jhcJszpylkcService.insertJhcJszpylkc(jhcJszpylkc));
    }

    /**
     * 修改金属制品原料库存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:jszpylkc:edit')")
    @Log(title = "金属制品原料库存录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JhcJszpylkc jhcJszpylkc)
    {
        return toAjax(jhcJszpylkcService.updateJhcJszpylkc(jhcJszpylkc));
    }

    /**
     * 删除金属制品原料库存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:jszpylkc:remove')")
    @Log(title = "金属制品原料库存录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(jhcJszpylkcService.deleteJhcJszpylkcByCDates(cDates));
    }
}
